package com.softbank.speaker;

import org.eclipse.paho.client.mqttv3.MqttException;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Test {
    public static void main(String[] args) {
        try {
            SpeakerMQTTClient.init(
                    "post-cn-6ja1t8wk10b",
                    "post-cn-6ja1t8wk10b.mqtt.aliyuncs.com",
                    "请填写自己的",
                    "请填写自己的",
                    "cloud_speaker",
                    "GID_CLOUD_SPEAKER",
                    "GID_CLOUD_SPEAKER" + "@@@OrderServer2", 0);

            Calendar calendar = Calendar.getInstance(Locale.CHINA);
            Date time = calendar.getTime();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateTime = simpleDateFormat.format(time);
            String orderNo = System.currentTimeMillis() + "";
            SpeakerMQTTClient.getInstance().speak(
                    SpeakerMQTTClient.TransType.ORDER,
                    SpeakerMQTTClient.PayType.ZFBZF,
                    "560",
                    orderNo,
                    dateTime,
                    dateTime,
                    "0101170003605"
            );
            Thread.sleep(1000);
            calendar = Calendar.getInstance(Locale.CHINA);
            time = calendar.getTime();
            dateTime = simpleDateFormat.format(time);
            orderNo = System.currentTimeMillis() + "";
            SpeakerMQTTClient.getInstance().speak(
                    SpeakerMQTTClient.TransType.ORDER,
                    SpeakerMQTTClient.PayType.HAPAY,
                    "1256",
                    orderNo,
                    dateTime,
                    dateTime,
                    "0101170003605"
            );

            Thread.sleep(1000);
            calendar = Calendar.getInstance(Locale.CHINA);
            time = calendar.getTime();
            dateTime = simpleDateFormat.format(time);
            orderNo = System.currentTimeMillis() + "";
            SpeakerMQTTClient.getInstance().speak(
                    SpeakerMQTTClient.TransType.ORDER,
                    SpeakerMQTTClient.PayType.WXZF,
                    "1256",
                    orderNo,
                    dateTime,
                    dateTime,
                    "0101170003605"
            );
            Thread.sleep(1000);
            calendar = Calendar.getInstance(Locale.CHINA);
            time = calendar.getTime();
            dateTime = simpleDateFormat.format(time);
            orderNo = System.currentTimeMillis() + "";
            SpeakerMQTTClient.getInstance().speak(
                    SpeakerMQTTClient.TransType.ORDER,
                    SpeakerMQTTClient.PayType.UPSMPAY,
                    "8999",
                    orderNo,
                    dateTime,
                    dateTime,
                    "0101170003605"
            );
        } catch (MqttException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
